package com.squid.cloud.common.enums;

import java.text.NumberFormat;

import lombok.Getter;

/**
 * 支付商品小类code
 */
@Getter
public enum ProductCodeEnum {
    _92("92#","34301", "92#汽油"),
    _95("95#","34401", "95#汽油"),
    _98("98#","34501", "98#汽油"),
    _0("0#","34601", "0#柴油"),
    U95("95#","34701", "95#汽油"),
    U98("98#","34801", "98#汽油"),
    YYZH("YYZH","YYZH","非油品账户");


    private String code;
    private String sign;
    private String displayName;

    private ProductCodeEnum(String code, String sign, String displayName) {
        this.code = code;
        this.sign = sign;
        this.displayName = displayName;
    }
    
    public static ProductCodeEnum code2OilNo(String code) {
        for (ProductCodeEnum o : ProductCodeEnum.values()) {
            if (o.getCode().equals(code)) {
                return o;
            }
        }
        return null;
    }

    public static String codeToName(String sign) {
        for (ProductCodeEnum o : ProductCodeEnum.values()) {
            if (sign.equalsIgnoreCase(o.getSign())) {
                return o.getCode();
            }else{
                return  "YYZH";
            }
        }
        return null;
    }

    public static String code(String sign) {
        String code = "";
        switch(sign)
        {
            case "34301":
                code = ProductCodeEnum._92.getCode();
                break;
            case "34401":
                code = ProductCodeEnum._95.getCode();
                break;
            case "34501":
                code = ProductCodeEnum._98.getCode();
                break;
            case "34601":
                code = ProductCodeEnum._0.getCode();
                break;
            case "34701":
                code = ProductCodeEnum.U95.getCode();
                break;
            case "34801":
                code = ProductCodeEnum.U98.getCode();
                break;
            default:
                code = ProductCodeEnum.YYZH.getCode();
                break;
        }
        return code;
    }

    //区分油和商品
    public static boolean sign(String sign) {
        boolean oil = false;
        for (ProductCodeEnum o : ProductCodeEnum.values()) {
            if (o.getSign().equals(sign)) {
                oil= true;
            }
        }
        return oil;
    }

    public static void main(String[] args) {
        Double songlin = 218111231.23d;

        NumberFormat nf = NumberFormat.getInstance();
        nf.setGroupingUsed(false);
        String dou_str = nf.format(songlin);
        System.out.println(String.valueOf(songlin.toString()));
        System.out.println(dou_str);
    }
}
